<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------

// 应用公共文件
/**
 * @导出CSV文件
 */
function export_csv($filename, $data){
    header("Content-type:text/csv");
    header("Content-Disposition:attachment;filename=".$filename);  // Content-Disposition指的是属性名，attachment指的是以附件形式下载，filename为默认保存文件名
    header('Cache-Control:must-revalidate,post-check=0,pre-check=0');  // Cache-Control:must-revalidate强制不缓存，post-check=0,pre-check=0是IE5中的防缓存
    header('Expires:0');  // 不缓存
    header('Pragma:public');
    echo chr(0xEF).chr(0xBB).chr(0xBF);  // 解决乱码
    echo $data;
}
